
TableGameItems = {
    [Item_Wudi]={
        [PModel]="daoju_02.png",
    },
    [Item_Baozou]={
        [PModel]="daoju_03.png",
    },
    [Item_TimerUp]={
        [PModel]="daoju_01.png",
    },
    [Item_TimerStop]={
        [PModel]="daoju_01.png",
    },
    [Item_HpItem]={
        [PModel]="wxueping.png",
    },
    [Item_Tips]={
        [PModel]="daoju_04.png",
    },
    [Item_AutoSl]={
        [PModel]="daoju_05.png",
    },
}


--------------------- 游戏道具按钮类
GameItems = {}
--这句是重定义元表的索引，必须要有，
GameItems.__index = GameItems
--模拟构造体，一般名称为new()
function GameItems:new(id, func, bBig)
    local self = {}   
    setmetatable(self, GameItems)   --必须要有
    
    if bBig == nil then
        bBig = true
    end
    
    self.id = id
    self._func = func
    
    --背景
    --self.sp_bg = CCSprite:createWithSpriteFrameName("gitemBG.png")
    ----图标
    self.sp_icon = CCSprite:createWithSpriteFrameName(TableGameItems[id][PModel])
    self.sp_icon:setScale(0.9)
    
    self._Menu = CCMenu:create()
    local pv = 1
    self._widthb = 80
    self._heightb = 80
    local bgfile = "gitemBG.png"
    if not bBig then
        self._widthb = 58
        self._heightb = 58
        bgfile = "gitemBG2.png"
        
        self.sp_icon:setScale(58/80 * 0.9)
    end
    
    self._menuItem = GFunc_CreateButtonP(bgfile, func, 1.2)
    
    self._menuItem:setPosition(gdccp(DWinSizeWidth/2, DWinSizeHeight/2 - 50))
    self._Menu:addChild(self._menuItem, 0, self.id)
    self._Menu:setPosition(gdccp(0,0))
    
    
    --数量背景
    self.priceBg = CCSprite:createWithSpriteFrameName("levelBg.png")
    --数量
    self._txtMyhpCut = CCMenuItemLabel:create(CCLabelTTF:create(0, "Arial", FontSizeMin))
    self._txtMyhpCut:setAnchorPoint(ccp(0.5, 0.5))
        
    return self  
end
function GameItems:getPosition()
end
function GameItems:setPosition(x,y)
    --self.sp_bg:setPosition(gdccp(x,y))
    self.sp_icon:setPosition(gdccp(x,y))
    self._menuItem:setPosition(gdccp(x,y))
    
    self.priceBg:setPosition(gdccp(x+self._widthb*0.63, y-self._heightb*0.38))
    self._txtMyhpCut:setPosition(gdccp(x+self._widthb*0.63, y-self._heightb*0.38))
end
function GameItems:addToChild(layer)
    layer:addChild(self._Menu)
    --layer:addChild(self.sp_bg)
    layer:addChild(self.sp_icon)
    
    layer:addChild(self.priceBg)
    layer:addChild(self._txtMyhpCut)
end
function GameItems:updateCut(v)
    self._txtMyhpCut:setString(v)
end
function GameItems:changeBgColor(color)
    self.priceBg:setColor(color)
end








